{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Vocabulary size: 2737\n",
      "Epoch 1/1 | Batch 0/72900 | train loss: 7.9154\n",
      "D: 户Ｖ秒秒秒外秒弩弩口口口摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊摊景景否否否否否否怔怔怔怔工工工工\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "媒媒媒媒媒媒媒媒媒北省省省省泾泾省泾泾蕙蕙镇镇镇镇镇桐桐桐桐桐桐抚抚抚抚抚摄抚池锡系系系复\n",
      "\n",
      "Epoch 1/1 | Batch 10/72900 | train loss: 5.3799\n",
      "Epoch 1/1 | Batch 20/72900 | train loss: 4.8318\n",
      "Epoch 1/1 | Batch 30/72900 | train loss: 4.7519\n",
      "Epoch 1/1 | Batch 40/72900 | train loss: 4.7245\n",
      "Epoch 1/1 | Batch 50/72900 | train loss: 4.7141\n",
      "Epoch 1/1 | Batch 60/72900 | train loss: 4.7102\n",
      "Epoch 1/1 | Batch 70/72900 | train loss: 4.7057\n",
      "Epoch 1/1 | Batch 80/72900 | train loss: 4.6991\n",
      "Epoch 1/1 | Batch 90/72900 | train loss: 4.6906\n",
      "Epoch 1/1 | Batch 100/72900 | train loss: 4.6784\n",
      "D: 北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北\n",
      "\n",
      "Epoch 1/1 | Batch 110/72900 | train loss: 4.6615\n",
      "Epoch 1/1 | Batch 120/72900 | train loss: 4.6330\n",
      "Epoch 1/1 | Batch 130/72900 | train loss: 4.6072\n",
      "Epoch 1/1 | Batch 140/72900 | train loss: 4.5789\n",
      "Epoch 1/1 | Batch 150/72900 | train loss: 4.5493\n",
      "Epoch 1/1 | Batch 160/72900 | train loss: 4.5284\n",
      "Epoch 1/1 | Batch 170/72900 | train loss: 4.5064\n",
      "Epoch 1/1 | Batch 180/72900 | train loss: 4.4898\n",
      "Epoch 1/1 | Batch 190/72900 | train loss: 4.4636\n",
      "Epoch 1/1 | Batch 200/72900 | train loss: 4.4411\n",
      "D: 北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北\n",
      "\n",
      "Epoch 1/1 | Batch 210/72900 | train loss: 4.4266\n",
      "Epoch 1/1 | Batch 220/72900 | train loss: 4.4117\n",
      "Epoch 1/1 | Batch 230/72900 | train loss: 4.3954\n",
      "Epoch 1/1 | Batch 240/72900 | train loss: 4.3863\n",
      "Epoch 1/1 | Batch 250/72900 | train loss: 4.3698\n",
      "Epoch 1/1 | Batch 260/72900 | train loss: 4.3587\n",
      "Epoch 1/1 | Batch 270/72900 | train loss: 4.3367\n",
      "Epoch 1/1 | Batch 280/72900 | train loss: 4.3109\n",
      "Epoch 1/1 | Batch 290/72900 | train loss: 4.2801\n",
      "Epoch 1/1 | Batch 300/72900 | train loss: 4.2401\n",
      "D: 北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北\n",
      "\n",
      "Epoch 1/1 | Batch 310/72900 | train loss: 4.2006\n",
      "Epoch 1/1 | Batch 320/72900 | train loss: 4.1611\n",
      "Epoch 1/1 | Batch 330/72900 | train loss: 4.1240\n",
      "Epoch 1/1 | Batch 340/72900 | train loss: 4.0929\n",
      "Epoch 1/1 | Batch 350/72900 | train loss: 4.0645\n",
      "Epoch 1/1 | Batch 360/72900 | train loss: 4.0359\n",
      "Epoch 1/1 | Batch 370/72900 | train loss: 4.0114\n",
      "Epoch 1/1 | Batch 380/72900 | train loss: 3.9857\n",
      "Epoch 1/1 | Batch 390/72900 | train loss: 3.9593\n",
      "Epoch 1/1 | Batch 400/72900 | train loss: 3.9393\n",
      "D: 北北北北北北北北北北北北北北北北北北北北北北北北京市\n",
      "北北北北京市\n",
      "北北京市\n",
      "北京市市\n",
      "北京市\n",
      "北京市市\n",
      "北京市\n",
      "北京市市\n",
      "北京市\n",
      "北京市市\n",
      "北京市\n",
      "北京市市\n",
      "北京市\n",
      "北京市市\n",
      "北京市\n",
      "北京市市\n",
      "京市\n",
      "\n",
      "Epoch 1/1 | Batch 410/72900 | train loss: 3.9231\n",
      "Epoch 1/1 | Batch 420/72900 | train loss: 3.9101\n",
      "Epoch 1/1 | Batch 430/72900 | train loss: 3.8871\n",
      "Epoch 1/1 | Batch 440/72900 | train loss: 3.8710\n",
      "Epoch 1/1 | Batch 450/72900 | train loss: 3.8654\n",
      "Epoch 1/1 | Batch 460/72900 | train loss: 3.8491\n",
      "Epoch 1/1 | Batch 470/72900 | train loss: 3.8250\n",
      "Epoch 1/1 | Batch 480/72900 | train loss: 3.7975\n",
      "Epoch 1/1 | Batch 490/72900 | train loss: 3.7685\n",
      "Epoch 1/1 | Batch 500/72900 | train loss: 3.7145\n",
      "D: 北北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市海\n",
      "北北京市市海\n",
      "北京市市海\n",
      "北京市市海\n",
      "北京市市海\n",
      "北京市市海\n",
      "北京市市海\n",
      "北京市市海\n",
      "京市\n",
      "\n",
      "Epoch 1/1 | Batch 510/72900 | train loss: 3.6707\n",
      "Epoch 1/1 | Batch 520/72900 | train loss: 3.6415\n",
      "Epoch 1/1 | Batch 530/72900 | train loss: 3.6022\n",
      "Epoch 1/1 | Batch 540/72900 | train loss: 3.5731\n",
      "Epoch 1/1 | Batch 550/72900 | train loss: 3.5369\n",
      "Epoch 1/1 | Batch 560/72900 | train loss: 3.5013\n",
      "Epoch 1/1 | Batch 570/72900 | train loss: 3.4637\n",
      "Epoch 1/1 | Batch 580/72900 | train loss: 3.4278\n",
      "Epoch 1/1 | Batch 590/72900 | train loss: 3.3900\n",
      "Epoch 1/1 | Batch 600/72900 | train loss: 3.3516\n",
      "D: \n",
      "北京市朝阳区区中路1\n",
      "北北京市海\n",
      "北北京市朝阳区区中路1\n",
      "北北京市朝阳区区中路1\n",
      "北北京市朝阳区区中路1\n",
      "北北京市海淀区中大京市市海淀区中大京市市海淀区中大京市市海淀区中大京市市海淀区中路1\n",
      "北京市\n",
      "\n",
      "Epoch 1/1 | Batch 610/72900 | train loss: 3.3171\n",
      "Epoch 1/1 | Batch 620/72900 | train loss: 3.2866\n",
      "Epoch 1/1 | Batch 630/72900 | train loss: 3.2496\n",
      "Epoch 1/1 | Batch 640/72900 | train loss: 3.2289\n",
      "Epoch 1/1 | Batch 650/72900 | train loss: 3.2108\n",
      "Epoch 1/1 | Batch 660/72900 | train loss: 3.1906\n",
      "Epoch 1/1 | Batch 670/72900 | train loss: 3.1671\n",
      "Epoch 1/1 | Batch 680/72900 | train loss: 3.1617\n",
      "Epoch 1/1 | Batch 690/72900 | train loss: 3.1228\n",
      "Epoch 1/1 | Batch 700/72900 | train loss: 3.1012\n",
      "D: 北京市朝阳区东北路1\n",
      "北京市海淀区西大街1\n",
      "北京市海淀区西大街1\n",
      "北京市海淀区中大厦11\n",
      "北京市海淀区大街1\n",
      "北京市海淀区中大厦11\n",
      "北京市海淀区大北京市海淀区中大厦11\n",
      "北京市海淀区大街1\n",
      "北京市海\n",
      "\n",
      "Epoch 1/1 | Batch 710/72900 | train loss: 3.0757\n",
      "Epoch 1/1 | Batch 720/72900 | train loss: 3.0457\n",
      "Epoch 1/1 | Batch 730/72900 | train loss: 3.0094\n",
      "Epoch 1/1 | Batch 740/72900 | train loss: 2.9803\n",
      "Epoch 1/1 | Batch 750/72900 | train loss: 2.9454\n",
      "Epoch 1/1 | Batch 760/72900 | train loss: 2.9168\n",
      "Epoch 1/1 | Batch 770/72900 | train loss: 2.8676\n",
      "Epoch 1/1 | Batch 780/72900 | train loss: 2.8277\n",
      "Epoch 1/1 | Batch 790/72900 | train loss: 2.7763\n",
      "Epoch 1/1 | Batch 800/72900 | train loss: 2.7407\n",
      "D: 北京市海淀区中关路11号\n",
      "北京市海淀区中关路11号\n",
      "北京市海淀区中关路11号\n",
      "北京市海淀区中关路11号\n",
      "北京市海淀区中关路11号\n",
      "北京市海淀区中关路11号\n",
      "北京市海淀区中关路11号\n",
      "北京市海淀区中关村\n",
      "\n",
      "Epoch 1/1 | Batch 810/72900 | train loss: 2.6919\n",
      "Epoch 1/1 | Batch 820/72900 | train loss: 2.6412\n",
      "Epoch 1/1 | Batch 830/72900 | train loss: 2.5861\n",
      "Epoch 1/1 | Batch 840/72900 | train loss: 2.5354\n",
      "Epoch 1/1 | Batch 850/72900 | train loss: 2.4994\n",
      "Epoch 1/1 | Batch 860/72900 | train loss: 2.4487\n",
      "Epoch 1/1 | Batch 870/72900 | train loss: 2.4021\n",
      "Epoch 1/1 | Batch 880/72900 | train loss: 2.3594\n",
      "Epoch 1/1 | Batch 890/72900 | train loss: 2.3120\n",
      "Epoch 1/1 | Batch 900/72900 | train loss: 2.2716\n",
      "D: 北京市海淀区中关村南大街1号\n",
      "北京市海淀区中关村南大街1号\n",
      "北京市海淀区中关村南大街1号\n",
      "北京市海淀区中关村南大街1号\n",
      "北京市海淀区中关村南大街1号\n",
      "北京市海淀区中关村南大厦\n",
      "北京市海淀区中关村南大街\n",
      "\n",
      "Epoch 1/1 | Batch 910/72900 | train loss: 2.2249\n",
      "Epoch 1/1 | Batch 920/72900 | train loss: 2.1716\n",
      "Epoch 1/1 | Batch 930/72900 | train loss: 2.1137\n",
      "Epoch 1/1 | Batch 940/72900 | train loss: 2.0685\n",
      "Epoch 1/1 | Batch 950/72900 | train loss: 2.0057\n",
      "Epoch 1/1 | Batch 960/72900 | train loss: 1.9565\n",
      "Epoch 1/1 | Batch 970/72900 | train loss: 1.9236\n",
      "Epoch 1/1 | Batch 980/72900 | train loss: 1.8575\n",
      "Epoch 1/1 | Batch 990/72900 | train loss: 1.8121\n",
      "Epoch 1/1 | Batch 1000/72900 | train loss: 1.7478\n",
      "D: 北京市朝阳区东三环南路甲1号\n",
      "北京市朝阳区东三环南路甲1号\n",
      "北京市朝阳区东三环南路甲1号\n",
      "北京市朝阳区东三环南路甲1号\n",
      "北京市朝阳区东三环南路甲1号\n",
      "北京市朝阳区东三环南路甲1号\n",
      "北京市朝阳区东三环南\n",
      "\n",
      "Epoch 1/1 | Batch 1010/72900 | train loss: 1.7014\n",
      "Epoch 1/1 | Batch 1020/72900 | train loss: 1.6491\n"
     ]
    }
   ],
   "source": [
    "# -*- coding: utf-8 -*-\n",
    "from char_rnn_beam import RNNTextGen\n",
    "from io import open\n",
    "\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    with open('./temp/beijing.txt', encoding='utf-8') as f:\n",
    "        text = f.read()\n",
    "    \n",
    "    model = RNNTextGen(text, seq_len=100)\n",
    "    log = model.fit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
